package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type Config struct {
	Mysql struct {
		User     string
		Password string
		Host     string
		Port     int
		Data     string
	}
	Redis struct {
		Host     string
		Password string
		DB       int
	}
	AliPay struct {
		AppId      string
		PrivateKey string
		NotifyURL  string
		ReturnURL  string
	}
}

var AddConfig Config

func Init() {
	viper.SetConfigFile("./appconfig/conf.yaml")
	if err := viper.ReadInConfig(); err != nil {
		fmt.Println("配置文件读取失败")
	}
	if err := viper.Unmarshal(&AddConfig); err != nil {
		fmt.Println("配置文件解析失败")
	}
	fmt.Println(AddConfig)
}
